/**
 date: 2018-4-17 21:24:25
 auther: fky
 */

import {Component, OnInit} from '@angular/core';
import {UserModel} from '../../../models/user.model';
import {ShareService} from '../../../service/share.service';
import {UsersService} from '../../../service/users.service';

@Component({
  selector: 'ngx-user-profile',
  styleUrls: ['./user-profile.component.scss'],
  templateUrl: './user-profile.component.html',
})

export class NgxUserProfileComponent implements OnInit {
  currentUser: UserModel = new UserModel();

  constructor(private usersService: UsersService, private shareService: ShareService) {
    shareService.getData().subscribe(localUser => {
      this.currentUser = localUser;
    });
  }


  ngOnInit(): void {
    this.usersService.getUserDetial(this.currentUser.id).subscribe((res: UserModel) => {
        this.currentUser = res;
        this.shareService.updateData(this.currentUser);
    });
  }
}
